/**
 */
package org.mro.grib.model.files.secondEdition.products.impl;

import java.nio.ByteBuffer;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.mro.grib.model.files.secondEdition.products.ProductDefinitionTemplate432;
import org.mro.grib.model.files.secondEdition.products.ProductsPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Product Definition Template432</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.mro.grib.model.files.secondEdition.products.impl.ProductDefinitionTemplate432Impl#getAnalysisOrForecastGeneratingProcessIdentifier <em>Analysis Or Forecast Generating Process Identifier</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.products.impl.ProductDefinitionTemplate432Impl#getHoursOfObservationalData <em>Hours Of Observational Data</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.products.impl.ProductDefinitionTemplate432Impl#getMinutesOfObservationalData <em>Minutes Of Observational Data</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.products.impl.ProductDefinitionTemplate432Impl#getIndicatorOfUnitOfTimeRange <em>Indicator Of Unit Of Time Range</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.products.impl.ProductDefinitionTemplate432Impl#getForecastTime <em>Forecast Time</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ProductDefinitionTemplate432Impl extends ProductDefinitionTemplate430Impl implements ProductDefinitionTemplate432 {
	/**
	 * The default value of the '{@link #getAnalysisOrForecastGeneratingProcessIdentifier() <em>Analysis Or Forecast Generating Process Identifier</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAnalysisOrForecastGeneratingProcessIdentifier()
	 * @generated
	 * @ordered
	 */
	protected static final byte ANALYSIS_OR_FORECAST_GENERATING_PROCESS_IDENTIFIER_EDEFAULT = 0x00;

	/**
	 * The cached value of the '{@link #getAnalysisOrForecastGeneratingProcessIdentifier() <em>Analysis Or Forecast Generating Process Identifier</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAnalysisOrForecastGeneratingProcessIdentifier()
	 * @generated
	 * @ordered
	 */
	protected byte analysisOrForecastGeneratingProcessIdentifier = ANALYSIS_OR_FORECAST_GENERATING_PROCESS_IDENTIFIER_EDEFAULT;

	/**
	 * The default value of the '{@link #getHoursOfObservationalData() <em>Hours Of Observational Data</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getHoursOfObservationalData()
	 * @generated
	 * @ordered
	 */
	protected static final short HOURS_OF_OBSERVATIONAL_DATA_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getHoursOfObservationalData() <em>Hours Of Observational Data</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getHoursOfObservationalData()
	 * @generated
	 * @ordered
	 */
	protected short hoursOfObservationalData = HOURS_OF_OBSERVATIONAL_DATA_EDEFAULT;

	/**
	 * The default value of the '{@link #getMinutesOfObservationalData() <em>Minutes Of Observational Data</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMinutesOfObservationalData()
	 * @generated
	 * @ordered
	 */
	protected static final byte MINUTES_OF_OBSERVATIONAL_DATA_EDEFAULT = 0x00;

	/**
	 * The cached value of the '{@link #getMinutesOfObservationalData() <em>Minutes Of Observational Data</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMinutesOfObservationalData()
	 * @generated
	 * @ordered
	 */
	protected byte minutesOfObservationalData = MINUTES_OF_OBSERVATIONAL_DATA_EDEFAULT;

	/**
	 * The default value of the '{@link #getIndicatorOfUnitOfTimeRange() <em>Indicator Of Unit Of Time Range</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getIndicatorOfUnitOfTimeRange()
	 * @generated
	 * @ordered
	 */
	protected static final byte INDICATOR_OF_UNIT_OF_TIME_RANGE_EDEFAULT = 0x00;

	/**
	 * The cached value of the '{@link #getIndicatorOfUnitOfTimeRange() <em>Indicator Of Unit Of Time Range</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getIndicatorOfUnitOfTimeRange()
	 * @generated
	 * @ordered
	 */
	protected byte indicatorOfUnitOfTimeRange = INDICATOR_OF_UNIT_OF_TIME_RANGE_EDEFAULT;

	/**
	 * The default value of the '{@link #getForecastTime() <em>Forecast Time</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getForecastTime()
	 * @generated
	 * @ordered
	 */
	protected static final int FORECAST_TIME_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getForecastTime() <em>Forecast Time</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getForecastTime()
	 * @generated
	 * @ordered
	 */
	protected int forecastTime = FORECAST_TIME_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ProductDefinitionTemplate432Impl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return ProductsPackage.Literals.PRODUCT_DEFINITION_TEMPLATE432;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public byte getAnalysisOrForecastGeneratingProcessIdentifier() {
		return analysisOrForecastGeneratingProcessIdentifier;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setAnalysisOrForecastGeneratingProcessIdentifier(byte newAnalysisOrForecastGeneratingProcessIdentifier) {
		byte oldAnalysisOrForecastGeneratingProcessIdentifier = analysisOrForecastGeneratingProcessIdentifier;
		analysisOrForecastGeneratingProcessIdentifier = newAnalysisOrForecastGeneratingProcessIdentifier;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ProductsPackage.PRODUCT_DEFINITION_TEMPLATE432__ANALYSIS_OR_FORECAST_GENERATING_PROCESS_IDENTIFIER, oldAnalysisOrForecastGeneratingProcessIdentifier, analysisOrForecastGeneratingProcessIdentifier));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public short getHoursOfObservationalData() {
		return hoursOfObservationalData;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setHoursOfObservationalData(short newHoursOfObservationalData) {
		short oldHoursOfObservationalData = hoursOfObservationalData;
		hoursOfObservationalData = newHoursOfObservationalData;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ProductsPackage.PRODUCT_DEFINITION_TEMPLATE432__HOURS_OF_OBSERVATIONAL_DATA, oldHoursOfObservationalData, hoursOfObservationalData));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public byte getMinutesOfObservationalData() {
		return minutesOfObservationalData;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMinutesOfObservationalData(byte newMinutesOfObservationalData) {
		byte oldMinutesOfObservationalData = minutesOfObservationalData;
		minutesOfObservationalData = newMinutesOfObservationalData;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ProductsPackage.PRODUCT_DEFINITION_TEMPLATE432__MINUTES_OF_OBSERVATIONAL_DATA, oldMinutesOfObservationalData, minutesOfObservationalData));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public byte getIndicatorOfUnitOfTimeRange() {
		return indicatorOfUnitOfTimeRange;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setIndicatorOfUnitOfTimeRange(byte newIndicatorOfUnitOfTimeRange) {
		byte oldIndicatorOfUnitOfTimeRange = indicatorOfUnitOfTimeRange;
		indicatorOfUnitOfTimeRange = newIndicatorOfUnitOfTimeRange;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ProductsPackage.PRODUCT_DEFINITION_TEMPLATE432__INDICATOR_OF_UNIT_OF_TIME_RANGE, oldIndicatorOfUnitOfTimeRange, indicatorOfUnitOfTimeRange));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getForecastTime() {
		return forecastTime;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setForecastTime(int newForecastTime) {
		int oldForecastTime = forecastTime;
		forecastTime = newForecastTime;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ProductsPackage.PRODUCT_DEFINITION_TEMPLATE432__FORECAST_TIME, oldForecastTime, forecastTime));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE432__ANALYSIS_OR_FORECAST_GENERATING_PROCESS_IDENTIFIER:
				return getAnalysisOrForecastGeneratingProcessIdentifier();
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE432__HOURS_OF_OBSERVATIONAL_DATA:
				return getHoursOfObservationalData();
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE432__MINUTES_OF_OBSERVATIONAL_DATA:
				return getMinutesOfObservationalData();
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE432__INDICATOR_OF_UNIT_OF_TIME_RANGE:
				return getIndicatorOfUnitOfTimeRange();
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE432__FORECAST_TIME:
				return getForecastTime();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE432__ANALYSIS_OR_FORECAST_GENERATING_PROCESS_IDENTIFIER:
				setAnalysisOrForecastGeneratingProcessIdentifier((Byte)newValue);
				return;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE432__HOURS_OF_OBSERVATIONAL_DATA:
				setHoursOfObservationalData((Short)newValue);
				return;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE432__MINUTES_OF_OBSERVATIONAL_DATA:
				setMinutesOfObservationalData((Byte)newValue);
				return;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE432__INDICATOR_OF_UNIT_OF_TIME_RANGE:
				setIndicatorOfUnitOfTimeRange((Byte)newValue);
				return;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE432__FORECAST_TIME:
				setForecastTime((Integer)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE432__ANALYSIS_OR_FORECAST_GENERATING_PROCESS_IDENTIFIER:
				setAnalysisOrForecastGeneratingProcessIdentifier(ANALYSIS_OR_FORECAST_GENERATING_PROCESS_IDENTIFIER_EDEFAULT);
				return;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE432__HOURS_OF_OBSERVATIONAL_DATA:
				setHoursOfObservationalData(HOURS_OF_OBSERVATIONAL_DATA_EDEFAULT);
				return;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE432__MINUTES_OF_OBSERVATIONAL_DATA:
				setMinutesOfObservationalData(MINUTES_OF_OBSERVATIONAL_DATA_EDEFAULT);
				return;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE432__INDICATOR_OF_UNIT_OF_TIME_RANGE:
				setIndicatorOfUnitOfTimeRange(INDICATOR_OF_UNIT_OF_TIME_RANGE_EDEFAULT);
				return;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE432__FORECAST_TIME:
				setForecastTime(FORECAST_TIME_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE432__ANALYSIS_OR_FORECAST_GENERATING_PROCESS_IDENTIFIER:
				return analysisOrForecastGeneratingProcessIdentifier != ANALYSIS_OR_FORECAST_GENERATING_PROCESS_IDENTIFIER_EDEFAULT;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE432__HOURS_OF_OBSERVATIONAL_DATA:
				return hoursOfObservationalData != HOURS_OF_OBSERVATIONAL_DATA_EDEFAULT;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE432__MINUTES_OF_OBSERVATIONAL_DATA:
				return minutesOfObservationalData != MINUTES_OF_OBSERVATIONAL_DATA_EDEFAULT;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE432__INDICATOR_OF_UNIT_OF_TIME_RANGE:
				return indicatorOfUnitOfTimeRange != INDICATOR_OF_UNIT_OF_TIME_RANGE_EDEFAULT;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE432__FORECAST_TIME:
				return forecastTime != FORECAST_TIME_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (analysisOrForecastGeneratingProcessIdentifier: "); //$NON-NLS-1$
		result.append(analysisOrForecastGeneratingProcessIdentifier);
		result.append(", hoursOfObservationalData: "); //$NON-NLS-1$
		result.append(hoursOfObservationalData);
		result.append(", minutesOfObservationalData: "); //$NON-NLS-1$
		result.append(minutesOfObservationalData);
		result.append(", indicatorOfUnitOfTimeRange: "); //$NON-NLS-1$
		result.append(indicatorOfUnitOfTimeRange);
		result.append(", forecastTime: "); //$NON-NLS-1$
		result.append(forecastTime);
		result.append(')');
		return result.toString();
	}

	/* (non-Javadoc)
	 * @see org.mro.grib.model.files.secondEdition.products.impl.ProductDefinitionTemplate430Impl#initialise(java.nio.ByteBuffer)
	 */
	@Override
	public void initialise(ByteBuffer buffer) {
		parameterCategory = buffer.get();
		parameterNumber = buffer.get();
		typeOfGeneratingProcess = buffer.get();
		observationGeneratingProcessIdentifier = buffer.get();
		analysisOrForecastGeneratingProcessIdentifier = buffer.get();
		hoursOfObservationalData = buffer.getShort();
		minutesOfObservationalData = buffer.get();
		indicatorOfUnitOfTimeRange = buffer.get();
		forecastTime = buffer.getInt();
		numberOfContributingSpectralBands = buffer.get();
		for(int i = 1 ; i < numberOfContributingSpectralBands + 1 ; i++)
		{
			contributingBandOffsets.add(Long.valueOf(buffer.position() + 10 * (i -1))); 
		}
	}
	
} //ProductDefinitionTemplate432Impl
